package com.dawan.sbjy.service.impl;

import com.dawan.sbjy.Config.Result;
import com.dawan.sbjy.Config.myExcep;
import com.dawan.sbjy.Rabbit.RabbitProducer;
import com.dawan.sbjy.dao.UserDao;
import com.dawan.sbjy.service.ifac.RegisteService;
import com.dawan.sbjy.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
@Service
public class RegisteServiceImpl implements RegisteService {
    @Autowired
    UserDao userDao;
    @Autowired
    RabbitProducer rabbitProducer;
    @Override
    public Result emailcode(String email) {
        //判断是否已经注册过
        int ifregiste=userDao.emailregistelength(email);
        if(ifregiste>0){
            throw new myExcep(500,"该邮箱已经注册！");
        }else{
            //将邮箱验证码发送添加到队列
            rabbitProducer.send(email);
            return ResultUtil.success("验证码已发送","发送成功");
        }

    }
}
